package org.greyhawk.samonitor.domain;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.PersistenceContext;
import javax.persistence.Table;

@Entity
@Table(name="S_FAGUI")
public class Statute implements Serializable{

	private static final long serialVersionUID = 1L;
	
	@PersistenceContext
    transient EntityManager entityManager;
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="S_FAGUI_ID")
	private Integer id;
	
	@ManyToOne
	@JoinColumn(name="S_SFAGUI_FANWEI_ID")
	private StatuteClassification classification;
	
	@Column(name="S_FAGUI_NAME")
	private String name;
	
	@Column(name="S_FAGUI_DETAIL")
	private String details;
	
	@Column(name="S_CLASS")
	private Integer sClass;
	
	@Column(name="S_FAGUI_HID")
	private Integer hId;
	
	@Column(name="S_FAGUI_SORT")
	private Integer sort;
	
	@Column(name="S_FAGUI_KEY_Y")
	private String yKey;
	
	@Column(name="S_FAGUI_KEY")
	private String key;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public StatuteClassification getClassification() {
		return classification;
	}

	public void setClassification(StatuteClassification classification) {
		this.classification = classification;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDetails() {
		return details;
	}

	public void setDetails(String details) {
		this.details = details;
	}

	public Integer getsClass() {
		return sClass;
	}

	public void setsClass(Integer sClass) {
		this.sClass = sClass;
	}

	public Integer gethId() {
		return hId;
	}

	public void sethId(Integer hId) {
		this.hId = hId;
	}

	public Integer getSort() {
		return sort;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}

	public String getyKey() {
		return yKey;
	}

	public void setyKey(String yKey) {
		this.yKey = yKey;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}
	
	public static final EntityManager entityManager() {
        EntityManager em = new Site().entityManager;
        if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)");
        return em;
    }
	
	public static  Statute findStatute(Integer id){
		return Statute.entityManager().find(Statute.class, id);
	}
	
	

}
